home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 12385 < prev    next >
Encoding:
Text File  |  1996-08-05  |  2.3 KB  |  60 lines

  1. Path: SOL1.GPS.CALTECH.EDU!CARL
  2. From: carl@SOL1.GPS.CALTECH.EDU (Carl J Lydick)
  3. Newsgroups: comp.os.vms,comp.sys.dec,comp.lang.c
  4. Subject: Re: getting correct local time in VAX C program
  5. Date: 31 Mar 1996 19:07:45 GMT
  6. Organization: HST Wide Field/Planetary Camera
  7. Distribution: world
  8. Message-ID: <4jml61$gth@gap.cco.caltech.edu>
  9. References: <4jec36$ff3@lastactionhero.rs.itd.umich.edu>
  10. Reply-To: carl@SOL1.GPS.CALTECH.EDU
  11. NNTP-Posting-Host: sol1.gps.caltech.edu
  12.  
  13. In article <4jec36$ff3@lastactionhero.rs.itd.umich.edu>, raffel@umich.edu (David Raffel) writes:
  14. =
  15. =I'm having a problem using the c localtime function to convert a
  16. ="timestamp" (represented in seconds since 1/1/1970) to a date
  17. =and time.  I'm running under VMS V5.5-2 and using VAXC V3.1.
  18. =
  19. =The problem is that the timestamp is being written out to a file
  20. =by a SUN which takes into account timezone information.  When I
  21. =read the timestamp on VMS and convert it, I get the correct date,
  22. =but the time is off by 5 hours.  I assume that this is because
  23. =the VAX doesn't use any timezone information and always returns
  24. =GMT.
  25. =
  26. =When I call time() to get the current time in seconds, the
  27. =time returned on VMS is different by 18000 seconds
  28.  
  29. That's 5 hours, by the way.
  30.  
  31. =from the
  32. =time returned on the SUN.
  33. =
  34. =Are there any routines available that will return the correct
  35. =local time, or any suggestions for how I can get the correct
  36. =time?
  37.  
  38. #include descrip
  39. #define ckstat(x) if (((stat = x) & 7) != 1) SYS$EXIT(stat)
  40.  
  41. main()
  42. {    unsigned long timadr[2], stat, SYS$EXIT(), SYS$GETTIM(), SYS$ASCTIM();
  43.     void puts();
  44.     char buffer[33];
  45.     $DESCRIPTOR(timbuf, buffer);
  46.  
  47.     ckstat(SYS$GETTIM(timadr));
  48.     ckstat(SYS$ASCTIM(&timbuf.dsc$w_length, &timbuf, timadr, 0));
  49.     buffer[timbuf.dsc$w_length] = '\0';
  50.     puts(buffer);
  51. }
  52. --------------------------------------------------------------------------------
  53. Carl J Lydick | INTERnet: CARL@SOL1.GPS.CALTECH.EDU | NSI/HEPnet: SOL1::CARL
  54.  
  55. Disclaimer:  Hey, I understand VAXen and VMS.  That's what I get paid for.  My
  56. understanding of astronomy is purely at the amateur level (or below).  So
  57. unless what I'm saying is directly related to VAX/VMS, don't hold me or my
  58. organization responsible for it.  If it IS related to VAX/VMS, you can try to
  59. hold me responsible for it, but my organization had nothing to do with it.
  60.